package com.qf.java2107.entity;

/**
 * 通用响应结果集
 *
 * @author YB
 * @date
 * @VERSION
 **/
public class ResultVO<T> {
    /**
     * 是否成功
     */
    private Boolean success;

    /**
     * 响应消息
     */
    private String message;
    /**
     * 附加数据
     */
    private T data;

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /**
     * 成功没有附加数据
     */
    public static ResultVO ok(String message) {
        ResultVO resultVO = new ResultVO();
        resultVO.setSuccess(true);
        resultVO.setMessage(message);
        return resultVO;
    }

    /**
     * 成功有添加数据
     */
    public static <T> ResultVO<T> ok(String message, T date) {
        ResultVO resultVO = new ResultVO();
        resultVO.setSuccess(true);
        resultVO.setMessage(message);
        resultVO.setData(date);
        return resultVO;
    }

    /**
     * 失败没有附加数据
     */
    public static ResultVO error(String message) {
        ResultVO resultVO = new ResultVO();
        resultVO.setSuccess(false);
        resultVO.setMessage(message);
        return resultVO;
    }

    /**
     * 失败有添加数据
     */
    public static <T> ResultVO<T> error(String message, T date) {
        ResultVO resultVO = new ResultVO();
        resultVO.setSuccess(false);
        resultVO.setMessage(message);
        resultVO.setData(date);
        return resultVO;
    }

}